<template>
  <div id="app">
    <nav-header></nav-header>
    <router-view />
    <message-box></message-box>
    <nav-footer></nav-footer>
    <tab-bar></tab-bar>
    
  </div>
</template>

<script>
import NavHeader from "@/components/NavHeader"
import MessageBox from "@/components/index/MessageBox"
import NavFooter from "@/components/NavFooter"
import TabBar from "@/components/TabBar"

export default {
  components: {
    NavHeader,
    MessageBox,
    NavFooter,
    TabBar,
  },
  data() {
    return {
      DialogData: {
        show: false
      }
    }
  },
  created () {
    this.isPhone();
  },
  mounted () {
    this.setFontSize();
    this.resize()
  },
  methods: {
    // 设置移动端字体
    setFontSize() {
      let width  = document.documentElement.clientWidth
      let sz = width* 100 / 750
      $("html").css("fontSize",`${sz}px`)
      window.onresize = function () {
        let width  = document.documentElement.clientWidth
        let sz = width* 100 / 750
        $("html").css("fontSize",`${sz}px`)
      }
    },
    //判断电脑是否是PC
      IsPC() {
        var userAgentInfo = navigator.userAgent;
        var Agents = ["Android", "iPhone",
            "SymbianOS", "Windows Phone",
            "iPad", "iPod"];
        var flag = true;
        for (var v = 0; v < Agents.length; v++) {
            if (userAgentInfo.indexOf(Agents[v]) > 0) {
              flag = false;
              break;
            }
        }
        return flag;
      },
      // 跳转
      isPhone() {
        let hasPc = this.IsPC()
        if (hasPc) {
            let http = window.location
            let control = http.protocol
            let host = http.host
            let url = `${control}//${host}`
            window.location.href = url 
        }
      },
      resize() {
        let self = this
         window.onresize = function name() {
            
              let hasPc = self.IsPC()
              if (hasPc) {
                let http = window.location
                let control = http.protocol
                let host = http.host
                let url = `${control}//${host}`
                window.location.href = url
              } 
        }
      },
  },
}
</script>

<style lang="scss">
html, body {
  width: 100%;
}
#app {
  width: 100%;
  max-width: 750px;
  margin: 0 auto;
  padding-top: 0.8rem;
  margin-bottom: 0.8rem;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
</style>
